package beans;

import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import entities.Circulo;

/**
 * Session Bean implementation class AdmFigurasBean
 */
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class AdmFigurasBean implements AdmFigurasBeanRemote {
	
    /**
     * Default constructor. 
     */
	@PersistenceContext(unitName="figurasUnit")
	EntityManager em;
	
	
    public AdmFigurasBean() {
        // TODO Auto-generated constructor stub
    }

    public void mensajePost(){
    	System.out.println("soy mensaje comun");
    }
    
	@Override
    @PostConstruct
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
	public void mensaje(){
		// TODO Auto-generated method stub
		System.out.println("soy postconstruct");
		System.out.println("estoy en el postconstruct");
    	Circulo circulo = new Circulo(2, "circulo2");
    	circulo.setRadio(44);
    	em.joinTransaction();
    	em.persist(circulo);
    	em.flush();
	}
}
